/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controlepgto.beans;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Thiago
 */


@NamedQueries({
    @NamedQuery(name = "Endereco.findAll", query = "SELECT e FROM Endereco e"),
    @NamedQuery(name = "Endereco.findByIdEndereco", query = "SELECT e FROM Endereco e WHERE e.idEndereco = :idEndereco"),
    @NamedQuery(name = "Endereco.findByCEPEndereco", query = "SELECT e FROM Endereco e WHERE e.cEPEndereco = :cEPEndereco"),
    @NamedQuery(name = "Endereco.findByTipologrEndereco", query = "SELECT e FROM Endereco e WHERE e.tipologrEndereco = :tipologrEndereco"),
    @NamedQuery(name = "Endereco.findByLogradouroEndereco", query = "SELECT e FROM Endereco e WHERE e.logradouroEndereco = :logradouroEndereco"),
    @NamedQuery(name = "Endereco.findByNumeroEndereco", query = "SELECT e FROM Endereco e WHERE e.numeroEndereco = :numeroEndereco"),
    @NamedQuery(name = "Endereco.findByComplEndereco", query = "SELECT e FROM Endereco e WHERE e.complEndereco = :complEndereco"),
    @NamedQuery(name = "Endereco.findByBairroEndereco", query = "SELECT e FROM Endereco e WHERE e.bairroEndereco = :bairroEndereco"),
    @NamedQuery(name = "Endereco.findByCidadeEndereco", query = "SELECT e FROM Endereco e WHERE e.cidadeEndereco = :cidadeEndereco"),
    @NamedQuery(name = "Endereco.findByUFEndereco", query = "SELECT e FROM Endereco e WHERE e.uFEndereco = :uFEndereco")})
    
@Entity
@Table(name = "endereco", catalog = "controlepgto", schema = "")
public class Endereco implements Serializable {
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idEndereco")
    private List<Cliente> clienteList;
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_Endereco", nullable = false)
    private Integer idEndereco;
    @Column(name = "CEP_Endereco", length = 8)
    private String cEPEndereco;
    @Column(name = "Tipo_logr_Endereco", length = 20)
    private String tipologrEndereco;
    @Column(name = "Logradouro_Endereco", length = 100)
    private String logradouroEndereco;
    @Column(name = "numero_Endereco")
    private Integer numeroEndereco;
    @Column(name = "Compl_Endereco", length = 45)
    private String complEndereco;
    @Column(name = "Bairro_Endereco", length = 45)
    private String bairroEndereco;
    @Column(name = "Cidade_Endereco", length = 45)
    private String cidadeEndereco;
    @Column(name = "UF_Endereco", length = 2)
    private String uFEndereco;

    public Endereco() {
    }

    public Endereco(Integer idEndereco) {
        this.idEndereco = idEndereco;
    }

    public Integer getIdEndereco() {
        return idEndereco;
    }

    public void setIdEndereco(Integer idEndereco) {
        Integer oldidEndereco = this.idEndereco;
        this.idEndereco = idEndereco;
        changeSupport.firePropertyChange("idEndereco", oldidEndereco, idEndereco);
    }

    public String getCEPEndereco() {
        return cEPEndereco;
    }

    public void setCEPEndereco(String cEPEndereco) {
        String oldcEPEndereco = this.cEPEndereco;
        this.cEPEndereco = cEPEndereco;
        changeSupport.firePropertyChange("cEPEndereco", oldcEPEndereco, cEPEndereco);
    }

    public String getTipologrEndereco() {
        return tipologrEndereco;
    }

    public void setTipologrEndereco(String tipologrEndereco) {
        String oldtipologrEndereco = this.tipologrEndereco;
        this.tipologrEndereco = tipologrEndereco;
        changeSupport.firePropertyChange("tipologrEndereco", oldtipologrEndereco, tipologrEndereco);
    }

    public String getLogradouroEndereco() {
        return logradouroEndereco;
    }

    public void setLogradouroEndereco(String logradouroEndereco) {
        String oldlogradouroEndereco = this.logradouroEndereco;
        this.logradouroEndereco = logradouroEndereco;
        changeSupport.firePropertyChange("logradouroEndereco", oldlogradouroEndereco, logradouroEndereco);
    }

    public Integer getNumeroEndereco() {
        return numeroEndereco;
    }

    public void setNumeroEndereco(Integer numeroEndereco) {
        Integer oldnumeroEndereco = this.numeroEndereco;
        this.numeroEndereco = numeroEndereco;
        changeSupport.firePropertyChange("numeroEndereco", oldnumeroEndereco, numeroEndereco);
    }

    public String getComplEndereco() {
        return complEndereco;
    }

    public void setComplEndereco(String complEndereco) {
        String oldcomplEndereco = this.complEndereco;
        this.complEndereco = complEndereco;
        changeSupport.firePropertyChange("complEndereco", oldcomplEndereco, complEndereco);
    }

    public String getBairroEndereco() {
        return bairroEndereco;
    }

    public void setBairroEndereco(String bairroEndereco) {
        String oldbairroEndereco = this.bairroEndereco;
        this.bairroEndereco = bairroEndereco;
        changeSupport.firePropertyChange("bairroEndereco", oldbairroEndereco, bairroEndereco);
    }

    public String getCidadeEndereco() {
        return cidadeEndereco;
    }

    public void setCidadeEndereco(String cidadeEndereco) {
        String oldcidadeEndereco = this.cidadeEndereco;
        this.cidadeEndereco = cidadeEndereco;
        changeSupport.firePropertyChange("cidadeEndereco", oldcidadeEndereco, cidadeEndereco);
    }

    public String getUFEndereco() {
        return uFEndereco;
    }

    public void setUFEndereco(String uFEndereco) {
        String olduFEndereco = this.uFEndereco;
        this.uFEndereco = uFEndereco;
        changeSupport.firePropertyChange("uFEndereco", olduFEndereco, uFEndereco);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idEndereco != null ? idEndereco.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Endereco)) {
            return false;
        }
        Endereco other = (Endereco) object;
        if ((this.idEndereco == null && other.idEndereco != null) || (this.idEndereco != null && !this.idEndereco.equals(other.idEndereco))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Endereco[ idEndereco=" + idEndereco + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

    @XmlTransient
    public List<Cliente> getClienteList() {
        return clienteList;
    }

    public void setClienteList(List<Cliente> clienteList) {
        this.clienteList = clienteList;
    }
}
